# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: douy.py
"""
'''
window.dataXl = s.toObject();
!function(){
    var res = window.dataXl;
    if (window.flagXL){
            window.wsXL.send(JSON.stringify(res));
    }
    else{
            var ws = new WebSocket("ws://127.0.0.1:9999");
            window.wsXL = ws;
            window.flagXL = true;
            ws.open = function(evt){};
            ws.onmessage = function(evt){
                ws.send(JSON.stringify(res));
            }
    }
}();
'''
import asyncio
import websockets
async def check_permit(websocket):
    send_text = 'xialuo'
    await websocket.send(send_text)
    return True
async def recv_msg(websocket):
    while 1:
        recv_text = await websocket.recv()
        print(recv_text)
async def main_logic(websocket, path):
    await check_permit(websocket)
    await recv_msg(websocket)
start_server = websockets.serve(main_logic, '127.0.0.1', 9999)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()

'''
私聊用户
A 直播间带货 手机
B直播间没人  手机
    去A直播间截流 
        根据发言找到ID 然后私聊
        
技术
    抖音 斗鱼  虎牙  都是一样的 
    
    ws 客户端和服务端通讯的协议
    私聊有接口的  根据ID来的  
        
        
'''


